
version 15
capture log close
set more off
clear
clear matrix
clear mata

if c(username)=="WB485280" {
		glo rootdir		"C:\Users\wb485280\OneDrive - WBG\radicalization"
		}
if c(username)=="WB382635" {
		glo rootdir		"C:\Users\wb382635\Dropbox\Unemp & daesh"
		}
if c(username)=="WB452275" {
		glo rootdir		"C:\Users\WB452275\Dropbox\Projects\Unemp & daesh"
		}
if c(username)=="sarurchaudhary" {
		glo rootdir		"/Users/sarurchaudhary/Dropbox/Unemp & daesh"
		}
if c(username)=="kartikabhatia" {
			glo rootdir		"/Users/kartikabhatia/Dropbox/Before2019/Unemp & daesh"
			}
			
		glo	datadir     "${rootdir}/Data/Raw data"
		glo outdir		"${rootdir}/Data/Working datasets"
		glo dodir		"${rootdir}/Dofiles"
        
		cd "${outdir}"
		
	    log using isis_prep, replace t
* ------------------------------------------------------------------------------
* Date : July 2017 [chkd oct 2021]


* Project : Mena Economic Monitor, Fall 2016 edition (MNACE, The World Bank)


* This do file prepares the ISIS fighters database for merge

* Database used : ISIS_fighters_new.dta.dta


* Output : isis.dta

* ------------------------------------------------------------------------------



*                      ----------------------------------
*                      --------ISIS fighters Data--------
*                      ----------------------------------


use "${datadir}/ISIS_fighters_new.dta", clear
drop if Country_resid ==""

***********************************************************
***checks for aspirations
replace Aspiration="." if Aspiration==""
gen temp1=0
replace temp1=1 if Aspiration=="."
drop temp1
********************

*           =================
*           Variables to keep
*           =================

g parent = !missing(Number_children)

set more off
tab Education, gen(isis_educ_status)
tab CivilStatus, gen(isis_marital_status)
tab ReligiousLevel, gen(isis_sharia_knw)
tab Aspiration, gen (isis_role)
tab job, gen(isis_emp_status)
tab Experience, gen(isis_jihad_exp)
tab Point_entry, gen(isis_entry)
tab Number_children, gen(isis_num_children)
tab parent,gen(isis_parent)
tab Country_origin, gen(isis_nationality)



*gen age=2016-YearofBirth
*drop if age <10
 

* Creating no. of fighters per country of residence

sort Country_resid, stable
gen id=_n

egen isis_nfighter_resid= count(id), by (Country_resid)
label variable isis_nfighter_resid "no. of fighters per country of residence " 

/* Creating no. of fighters per country of citizenship

egen nfighter_nat= count(id), by (Country_origin)
label variable nfighter_nat "no. of fighters per country of citizenship"*/

* ------------------------------------------------------------------------------

* Collapsing data to create country level estimates (keeping the same labels)


foreach v of var age isis_educ_status1 - isis_nationality81 isis_nfighter_resid  {
 	local l`v' : variable label `v'
        if `"`l`v''"' == "" {
 		local l`v' "`v'"
  	}
  }
collapse age isis_educ_status1 - isis_nationality81 (max)isis_nfighter_resid, by(Country_resid)


 foreach v of var age isis_educ_status1 - isis_nationality81 isis_nfighter_resid {
 	label var `v' "`l`v''"
 }


* ------------------------------------------------------------------------------


* Adding countries that are in WDI but not in ISIS database (for merge)

sort Country_resid, stable
gen country_temp=Country_resid
gen year=2013


 insobs 110, before(1)
 replace country_temp = "Angola" in 1
 replace year = 2013 in 1
 replace country_temp = "Argentina" in 2
 replace year = 2013 in 2
 replace country_temp = "Armenia" in 3
 replace year = 2013 in 3
 replace country_temp = "Bangladesh" in 4
 replace year = 2013 in 4
 replace country_temp= "Belarus" in 5
 replace year = 2013 in 5
 replace country_temp= "Belize" in 6
 replace year = 2013 in 6
 replace country_temp = "Benin" in 7
 replace year = 2013 in 7
 replace country_temp = "Bhutan" in 8
 replace year = 2013 in 8
 replace country_temp = "Bolivia" in 9
 replace year = 2013 in 9
 replace country_temp = "Botswana" in 10
 replace year = 2013 in 10
 replace country_temp = "Brazil" in 11
 replace year = 2013 in 11
 replace country_temp = "Burkina Faso" in 12
 replace year = 2013 in 12
 replace country_temp = "Burundi" in 13
 replace year = 2013 in 13
 replace country_temp= "Cambodia" in 14
 replace year = 2013 in 14
 replace country_temp = "Central African Republic" in 15
 replace year = 2013 in 15
 replace country_temp = "Chad" in 16
 replace year = 2013 in 16
 replace country_temp = "Chile" in 17
 replace year = 2013 in 17
 replace country_temp = "Colombia" in 18
 replace year = 2013 in 18
 replace country_temp = "Comoros" in 19
 replace year = 2013 in 19
 replace country_temp = "Congo Brazzaville" in 20
 replace year = 2013 in 20
 replace country_temp = "Congo Kinshasa" in 21
 replace year = 2013 in 21
 replace country_temp = "Costa Rica" in 22
 replace year = 2013 in 22
 replace country_temp = "Croatia" in 23
 replace year = 2013 in 23
 replace country_temp= "Cuba" in 24
 replace year = 2013 in 24
 replace country_temp = "Cyprus" in 25
 replace year = 2013 in 25
 replace country_temp = "Czech Republic" in 26
  replace year = 2013 in 26
 replace country_temp = "Djibouti" in 27
 replace year = 2013 in 27
 replace country_temp = "Dominican republic" in 28
 replace year = 2013 in 28
 replace country_temp = "Ecuador" in 29
 replace year = 2013 in 29
 replace country_temp = "El Salvador" in 30
 replace year = 2013 in 30
 replace country_temp = "Equatorial Guinea" in 31
 replace year = 2013 in 31
 replace country_temp = "Eritrea" in 32
 replace year = 2013 in 32
 replace country_temp = "Estonia" in 33
 replace year = 2013 in 33
 replace country_temp = "Ethiopia" in 34
 replace year = 2013 in 34
 replace country_temp = "Finland" in 35
 replace year = 2013 in 35
 replace country_temp = "Gabon" in 36
 replace year = 2013 in 36
 replace country_temp = "Gambia, The" in 37
 replace year = 2013 in 37
 replace country_temp = "Ghana" in 38
 replace year = 2013 in 38
replace country_temp = "Greece" in 39
 replace year = 2013 in 39
 replace country_temp = "Guatemala" in 40
 replace year = 2013 in 40
 replace country_temp = "Guinea" in 41
 replace year = 2013 in 41
 replace country_temp = "Guinea-Bissau" in 42
 replace year = 2013 in 42
 replace country_temp = "Guyana" in 43
 replace year = 2013 in 43
 replace country_temp = "Haiti" in 44
 replace year = 2013 in 44
 replace country_temp = "Honduras" in 45
 replace year = 2013 in 45
 replace country_temp = "Hong Kong" in 46
 replace year = 2013 in 46
 replace country_temp= "Hungary" in 47
 replace year = 2013 in 47
 replace country_temp = "Iceland" in 48
 replace year = 2013 in 48
  replace country_temp = "Israel" in 49
 replace year = 2013 in 49
 replace country_temp = "Italy" in 50
 replace year = 2013 in 50
 replace country_temp = "Ivory Coast" in 51
 replace year = 2013 in 51
 replace country_temp = "Jamaica" in 52
 replace year = 2013 in 52
 replace country_temp = "Japan" in 53
 replace year = 2013 in 53
 replace country_temp = "Laos" in 54
 replace year = 2013 in 54
 replace country_temp = "Latvia" in 55
 replace year = 2013 in 55
replace country_temp = "Lesotho" in 56
 replace year = 2013 in 56
 replace country_temp = "Liberia" in 57
 replace year = 2013 in 57
 replace country_temp = "Lithuania" in 58
 replace year = 2013 in 58
 replace country_temp = "Luxembourg" in 59
 replace year = 2013 in 59 
 replace country_temp = "Madagascar" in 60
 replace year = 2013 in 60
 replace country_temp = "Malawi" in 61
 replace year = 2013 in 61
 replace country_temp= "Mali" in 62
 replace year = 2013 in 62
 replace country_temp = "Malta" in 63
 replace year = 2013 in 63
replace country_temp = "Mauritius" in 64
 replace year = 2013 in 64
 replace country_temp = "Mexico" in 65
 replace year = 2013 in 65
 replace country_temp = "Moldova" in 66
 replace year = 2013 in 66
 replace country_temp = "Mongolia" in 67
 replace year = 2013 in 67
 replace country_temp = "Montenegro" in 68
 replace year = 2013 in 68
 replace country_temp = "Mozambique" in 69
 replace year = 2013 in 69
 replace country_temp = "Myanmar" in 70
 replace year = 2013 in 70
 replace country_temp = "Nagorno Karbakh" in 71
 replace year = 2013 in 71
 replace country_temp= "Namibia" in 72
 replace year = 2013 in 72
 replace country_temp = "Nepal" in 73
 replace year = 2013 in 73
 replace country_temp = "New Zealand" in 74
 replace year = 2013 in 74
 replace country_temp = "Nicargua" in 75
 replace year = 2013 in 75
 replace country_temp = "Niger" in 76
 replace year = 2013 in 76
 replace country_temp = "Nigeria" in 77
 replace year = 2013 in 77
 replace country_temp = "North Korea" in 78
 replace year = 2013 in 78
 replace country_temp = "Northern Cyprus" in 79
 replace year = 2013 in 79
 replace country_temp = "Oman" in 80
 replace year = 2013 in 80
 replace country_temp = "Panama" in 81
 replace year = 2013 in 81
 replace country_temp = "Paraguay" in 82
 replace year = 2013 in 82
 replace country_temp = "Peru" in 83
 replace year = 2013 in 83
 replace country_temp = "Philippines" in 84
 replace year = 2013 in 84
 replace country_temp= "Portugal" in 85
 replace year = 2013 in 85
 replace country_temp = "Puerto Rico" in 86
 replace year = 2013 in 86
 replace country_temp = "Romania" in 87
 replace year = 2013 in 87
 replace country_temp = "Rwanda" in 88
 replace year = 2013 in 88
 replace country_temp = "Senegal" in 89
 replace year = 2013 in 89
replace country_temp = "Sierra Leone" in 90
 replace year = 2013 in 90
 replace country_temp = "Singapore" in 91
 replace year = 2013 in 91
 replace country_temp = "Slovakia" in 92
 replace year = 2013 in 92
 replace country_temp = "Slovenia" in 93
 replace year = 2013 in 93
 replace country_temp = "Somaliland" in 94
 replace year = 2013 in 94
 replace country_temp = "South Korea" in 95
 replace year = 2013 in 95
 replace country_temp = "South Sudan" in 96
 replace year = 2013 in 96
 replace country_temp= "Sri Lanka" in 97
 replace year = 2013 in 97
  replace country_temp = "Suriname" in 98
 replace year = 2013 in 98
 replace country_temp = "Swaziland" in 99
 replace year = 2013 in 99
 replace country_temp = "Taiwan" in 100
 replace year = 2013 in 100
 replace country_temp = "Tanzania" in 101
 replace year = 2013 in 101
 replace country_temp = "Thailand" in 102
 replace year = 2013 in 102
 replace country_temp = "Togo" in 103
 replace year = 2013 in 103
replace country_temp= "Uganda" in 104
 replace year = 2013 in 104
 replace country_temp = "United Arab Emirates" in 105
 replace year = 2013 in 105
 replace country_temp = "Uruguay" in 106
 replace year = 2013 in 106
 replace country_temp = "Venezuela" in 107
 replace year = 2013 in 107
 replace country_temp = "Vietnam" in 108
 replace year = 2013 in 108
 replace country_temp = "Zambia" in 109
 replace year = 2013 in 109
 replace country_temp = "Zimbabwe" in 110
 replace year = 2013 in 110
 

 * Creating numeric variable for countries

sort  country_temp, stable
encode country_temp, gen(ctry)
drop country_temp

sort ctry year

*note: Dropped age<10  (ISIS)
note: ISIS data is most likely to be representative of foreign fighters. I suggest removing Iraq and Syria when analyzing. (ISIS)
note: Have used country of residence (and not country of nationality) for merging. (ISIS)

save "${outdir}/isis.dta", replace

log close
